package app.r_teenus.backend.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;
import javax.persistence.OneToOne;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;
import javax.persistence.Transient;

@Entity
@Table(name = "SERVICE_ORDER")
public class ServiceOrder implements Serializable {

	private static final long serialVersionUID = -3377428415438225164L;
	private Integer id = null;
	// private Customer customer = null;
	private SoStatusType soStatusType = null;
	private ServiceRequest serviceRequest = null;
	private Date statusChanged = null;
	private Employee statusChangedBy = null;
	private Double price = null;
	private String note = null;
	private Employee createdBy = null;
	private Date created = null;
	private Employee updatedBy = null;
	private Date updated = null;
	private List<ServiceOrder> list = new ArrayList<ServiceOrder>();
	private boolean canRemove = false;
	private ServiceAction serviceAction = null;
	private ServicePart servicePart = null;
	private List<SoStatusType> soStatusTypeList = new ArrayList<SoStatusType>();
	private ServiceDevice serviceDevice = null;
	/**
	 * Gets id (primary key).
	 */
	@Id
	@Column(name = "SERVICE_ORDER")
	@SequenceGenerator(name = "service_order_id", sequenceName = "service_order_id", allocationSize = 1)
	@GeneratedValue(generator = "service_order_id")
	public Integer getId() {
		return id;
	}

	public void setId(Integer id) {
		this.id = id;
	}

	// @OneToOne
	// @JoinColumn(name = "CUSTOMER_FK", nullable = false)
	// public Customer getCustomer() {
	// return customer;
	// }
	//
	// public void setCustomer(Customer customer) {
	// this.customer = customer;
	// }

	@OneToOne
	@JoinColumn(name = "SO_STATUS_TYPE_FK", nullable = false)
	public SoStatusType getSoStatusType() {
		return soStatusType;
	}

	public void setSoStatusType(SoStatusType soStatusType) {
		this.soStatusType = soStatusType;
	}

	@OneToOne
	@JoinColumn(name = "SERVICE_REQUEST_FK", nullable = false)
	public ServiceRequest getServiceRequest() {
		return serviceRequest;
	}

	public void setServiceRequest(ServiceRequest serviceRequest) {
		this.serviceRequest = serviceRequest;
	}

	@Column(name = "STATUS_CHANGED")
	public Date getStatusChanged() {
		return statusChanged;
	}

	public void setStatusChanged(Date statusChanged) {
		this.statusChanged = statusChanged;
	}

	@OneToOne
	@JoinColumn(name = "STATUS_CHANGED_BY", nullable = true)
	public Employee getStatusChangedBy() {
		return statusChangedBy;
	}

	public void setStatusChangedBy(Employee statusChangedBy) {
		this.statusChangedBy = statusChangedBy;
	}

	@Column(name = "PRICE_TOTAL")
	public Double getPrice() {
		return price;
	}

	public void setPrice(Double price) {
		this.price = price;
	}

	public String getNote() {
		return note;
	}

	public void setNote(String note) {
		this.note = note;
	}

	@OneToOne
	@JoinColumn(name = "CREATED_BY", nullable = false)
	public Employee getCreatedBy() {
		return createdBy;
	}

	public void setCreatedBy(Employee createdBy) {
		this.createdBy = createdBy;
	}

	public Date getCreated() {
		return created;
	}

	public void setCreated(Date created) {
		this.created = created;
	}

	@OneToOne
	@JoinColumn(name = "UPDATED_BY", nullable = true)
	public Employee getUpdatedBy() {
		return updatedBy;
	}

	public void setUpdatedBy(Employee updatedBy) {
		this.updatedBy = updatedBy;
	}

	public Date getUpdated() {
		return updated;
	}

	public void setUpdated(Date updated) {
		this.updated = updated;
	}

	@Transient
	public List<ServiceOrder> getList() {
		return list;
	}

	public void setList(List<ServiceOrder> list) {
		this.list = list;
	}

	@Transient
	public boolean isCanRemove() {
		return canRemove;
	}

	public void setCanRemove(boolean canRemove) {
		this.canRemove = canRemove;
	}

	@OneToOne(mappedBy = "serviceOrder")
	public ServiceAction getServiceAction() {
		return serviceAction;
	}

	public void setServiceAction(ServiceAction serviceAction) {
		this.serviceAction = serviceAction;
	}

	@OneToOne(mappedBy = "serviceOrder")
	public ServicePart getServicePart() {
		return servicePart;
	}

	public void setServicePart(ServicePart servicePart) {
		this.servicePart = servicePart;
	}

	@Transient
	public List<SoStatusType> getSoStatusTypeList() {
		return soStatusTypeList;
	}

	public void setSoStatusTypeList(List<SoStatusType> soStatusTypeList) {
		this.soStatusTypeList = soStatusTypeList;
	}

	@OneToOne(mappedBy = "serviceOrder")
	public ServiceDevice getServiceDevice() {
		return serviceDevice;
	}

	public void setServiceDevice(ServiceDevice serviceDevice) {
		this.serviceDevice = serviceDevice;
	}

	
	
}
